package com.woniu.airent.service.impl;

import com.woniu.airent.dto.HouseDto;
import com.woniu.airent.mapper.SearchMapMapper;
import com.woniu.airent.service.SearchMapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SearchMapServiceImpl implements SearchMapService {
    @Autowired
    SearchMapMapper searchMapMapper;

    @Override
    public List<HouseDto> findHouseByMap(String areaName, String house, String[] moneys, String[] areas) {
        int minMoney=0;
        int maxMoney=0;
        int minArea=0;
        int maxArea=0;

        for(int i=0;i<=moneys.length;i++){
            minMoney=Integer.parseInt(moneys[0]);
            maxMoney=Integer.parseInt(moneys[moneys.length-1]);
        }

        for(int i=0;i<=areas.length;i++){
            minArea=Integer.parseInt(areas[0]);
            maxArea=Integer.parseInt(areas[areas.length-1]);
        }
        List<HouseDto> houses = searchMapMapper.findHouseByMap(areaName, house, maxMoney, minMoney, maxArea, minArea);
        return houses;
    }

}
